package com.ruoyi.canteen.service.impl;

import java.util.List;

import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.canteen.mapper.CanteenCpClassMapper;
import com.ruoyi.canteen.domain.CanteenCpClass;
import com.ruoyi.canteen.service.ICanteenCpClassService;

/**
 * 菜品分类Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-09-08
 */
@Service
public class CanteenCpClassServiceImpl implements ICanteenCpClassService 
{
    @Autowired
    private CanteenCpClassMapper canteenCpClassMapper;

    /**
     * 查询菜品分类
     * 
     * @param id 菜品分类主键
     * @return 菜品分类
     */
    @Override
    public CanteenCpClass selectCanteenCpClassById(Long id)
    {
        return canteenCpClassMapper.selectCanteenCpClassById(id);
    }

    /**
     * 查询菜品分类列表
     * 
     * @param canteenCpClass 菜品分类
     * @return 菜品分类
     */
    @Override
    @DataScope(deptAlias = "U")
    public List<CanteenCpClass> selectCanteenCpClassList(CanteenCpClass canteenCpClass)
    {
        return canteenCpClassMapper.selectCanteenCpClassList(canteenCpClass);
    }

    /**
     * 新增菜品分类
     * 
     * @param canteenCpClass 菜品分类
     * @return 结果
     */
    @Override
    public int insertCanteenCpClass(CanteenCpClass canteenCpClass)
    {
        canteenCpClass.setCreateTime(DateUtils.getNowDate());
        return canteenCpClassMapper.insertCanteenCpClass(canteenCpClass);
    }

    /**
     * 修改菜品分类
     * 
     * @param canteenCpClass 菜品分类
     * @return 结果
     */
    @Override
    public int updateCanteenCpClass(CanteenCpClass canteenCpClass)
    {
        return canteenCpClassMapper.updateCanteenCpClass(canteenCpClass);
    }

    /**
     * 批量删除菜品分类
     * 
     * @param ids 需要删除的菜品分类主键
     * @return 结果
     */
    @Override
    public int deleteCanteenCpClassByIds(Long[] ids)
    {
        return canteenCpClassMapper.deleteCanteenCpClassByIds(ids);
    }

    /**
     * 删除菜品分类信息
     * 
     * @param id 菜品分类主键
     * @return 结果
     */
    @Override
    public int deleteCanteenCpClassById(Long id)
    {
        return canteenCpClassMapper.deleteCanteenCpClassById(id);
    }

    /**
     * 通过门店ID，获取菜品分类列表
     * @param mdId 门店ID
     * @return
     */
    @Override
    public List<CanteenCpClass> selectCpClassListByMdId(Integer mdId){
        return canteenCpClassMapper.selectCpClassListByMdId(mdId);
    }
}
